#ifndef _SIGNAL_HPP_20120609
#define _SIGNAL_HPP_20120609

#include <iostream>
#include <fstream>
#include <string>

#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <fstream>

#define SIG_RELOAD SIGHUP
#define SIG_STOP   SIGTERM

class Signal
{
	public :
		struct signal_t
		{
			int     signo;
			const char   *signame;
			const char   *name;
			void  (*handler)(int signo);
		};

		enum
		{
			OP_NOTHING  = 0,
			OP_RELOAD   = 1,
			OP_STOP     = 2,
		};

	public :
		Signal();
		~Signal();

		int init(const std::string & pid_file);
		int  signal_process(const std::string & pid_file, const std::string & name);

		pid_t get_pid();
		void  log_pid();
	public :
		static void handler(int signo);
		
	public :
		static signal_t _signals[];
		static int      _op;

		std::string     _pid_file;
		pid_t           _pid;

		bool            _init;
};

#endif

